package com.mycompany.project.client.chee;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Image;
import com.mycompany.project.client.duch.MiniRSGUI;

/**
 * This class will represent the rover and its functions.
 * @author LeeNou
 *
 */
public class Rover {
	/**
	 * Stores current rover row position.
	 */
	private static int rRow;
	/**
	 * Stores current rover column position.
	 */
	private static int rCol;
	/**
	 * rover image.
	 */
	private static Image roverImg;
	/**
	 * Initialized the rover.
	 */
	public static void initRover() {
		roverImg = new Image("images/Rover.jpg");
		rRow = 0;
		rCol = 0;
	}
	/**
	 * Place over on map.
	 */
	public static void placeOnMap() {
		removeRoverFromMap();
		MiniRSGUI.getMiniGrid().setWidget(rRow, rCol, roverImg);
		roverImg.setTitle(("Rover @(" + rCol + "," + rRow + ")"));
		Window.alert("Rover @("  + rCol + "," + rRow + ")");
	}
	/**
	 * Check if rover is on this row or col.
	 * @param row the row to check.
	 * @param col the col to check.
	 * @return true if this row and col is where the rover is at.
	 */
	public static boolean isOnRover(final int row, final int col) {
		return (rRow == row && rCol == col);
	}
	/**
	 * remove rover from the map.
	 */
	private static void removeRoverFromMap() {
		MapGUI.getGrid().remove(roverImg);
	}
	/**
	 * Random pick row and col.
	 */
	public static void randPickRowNCol() {
		//get a unique row and column
		int []rw = new int[2];
		rw = GPSData.getUniqueXY();
		rRow = rw[0];
		rCol = rw[1];
	}
	/**
	 * Display shortest distance to module m and its optimal route to module
	 * m to move into position.
	 * @param m the module to check.
	 */
	public static void nextModule(final Module m) {
	}
	/**
	 * Set rover row.
	 * @param row the row to set.
	 */
	public static void setRoverRow(final int row) {
		rRow = row;
	}
	/**
	 * Set rover col.
	 * @param col the value to set for col.
	 */
	public static void setRoverCol(final int col) {
		rCol = col;
	}
	/**
	 * Get rover row.
	 * @return rRow.
	 */
	public static int getRoverRow() {
		return rRow;
	}
	/**
	 * Get rover column.
	 * @return rCol.
	 */
	public static int getRoverCol() {
		return rCol;
	}

}
